<?php
    session_start();
    include "/opt/lampp/htdocs/dom/html/db.php";
    $user = @$_POST['user'];
    $passwd = @$_POST['passwd'];
    $authcode = @$_POST['authcode'];
    if(!isset($user) or $user ==""){
    die("账号不能为空");
    }
    if(!isset($passwd) or $passwd ==""){
        die("密码不能为空");
    }
    if(!isset($authcode) or $authcode ==""){
        die("验证码不能为空");
    }
    if(strtoupper($_SESSION["authcode"]) != strtoupper($authcode)){
        var_dump($_SESSION["authcode"]);
        var_dump($authcode);
        die("验证码不正确");
    }

    $sql = "select * from user where user= '$user' and passwd = '$passwd'";
    $db = new DB();
    $result_list = $db->select($sql);
     // 判断
 if(count($result_list) == 1){
    $_SESSION['username'] = $user;
    header("location:../html/index.php");
    }else{
    die("账号或密码错误");
    }

    
?>